#define _CRT_SECURE_NO_WARNINGS 1
bool isValid(char* s) {
    int top = -1;
    char stack[strlen(s) + 1];
    char map[256] = { 0 };
    map[')'] = '(';
    map['}'] = '{';
    map[']'] = '[';

    for (int i = 0; s[i] != '\0'; i++) {
        char c = s[i];
        if (c == '(' || c == '{' || c == '[') {
            stack[++top] = c;
        }
        else if (c == ')' || c == '}' || c == ']') {
            if (top == -1 || stack[top--] != map[c]) {
                return false;
            }
        }
    }
    return top == -1;
}